import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const state = {
  token: "",
  FormData: {},
  height: "",
}

const mutations = {
  setToken: (state, token) => {
    if (token) {
      state.token = token
    } else {
      state.token = ""
    }
  },
  setHeight: ( state, height ) => {
    if (height) {
      state.height = height
    } else {
      state.height = ""
    }
  },

  getFormData: (state, msg) => {
    state.FormData = msg
  }
}

const actions = {
  emitToken: ({ commit }, token) => {
    commit("setToken", token)
  }
}

const getters = {
  token: state => state.token,
  height: state => state.height
}
export default new Vuex.Store({
  state,
  mutations,
  actions,
  getters,
});
